﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using QQHelper;

namespace QQLogin
{
    /// <summary>
    /// QQGroupManagerWin.xaml 的交互逻辑
    /// </summary>
    public partial class QQGroupManagerCtrl : UserControl
    {
        public QQGroupManagerCtrl()
        {
            InitializeComponent();
            Init();
        }
        private List<QQGroupInfo> _GroupList = new List<QQGroupInfo>();
        public void Init()
        {
            string jsonstr = QQHelper.HttpHelper.GetQQqunJson(Global.QQNum, Global.Gtk, Global.Cookie);
            QQGrouplist groupList = QQ.JsonHelper.GetQQGroupList(jsonstr);
            if (groupList == null) return;
            _GroupList = groupList.group;
            lv_Group.ItemsSource = _GroupList;
            lv_Group.DisplayMemberPath = "groupname";
            lv_Group.SelectionChanged += new SelectionChangedEventHandler(lv_Group_SelectionChanged);
        }

        void lv_Group_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            QQGroupInfo group = lv_Group.SelectedItem as QQGroupInfo;
            if (group == null) return;
            string jsonstr = QQHelper.HttpHelper.GetQQMember(Global.QQNum, group.groupid, Global.Gtk, Global.Cookie);
            List<QQMember> member = QQ.JsonHelper.GetMemberList(jsonstr);
            lv_Member.ItemsSource = member;
        }
    }
}
